package com.mxpio.erp.common.quality.entity;

import com.mxpio.erp.common.jpa.model.Notice;
import com.mxpio.erp.common.jpa.model.NoticeLine;
import com.mxpio.erp.common.vo.OrderExcuteLineVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_QUALITY_SONOTICE")
@Schema(description="报废出库通知单")
public class ScrapOutNotice extends Notice {

	private static final long serialVersionUID = 1L;

	@Override
    public String initTypeCode() {
        return "N02";
    }

    @Transient
    private ScrapOutApply scrapOutApply;
    @Transient
    private List<ScrapOutNoticeLine> scrapOutNoticeLines;
	@Override
	public NoticeLine createLine(OrderExcuteLineVo orderExcuteVo) {
        NoticeLine noticeLine = new ScrapOutNoticeLine();
        noticeLine.setOriginBizLineNo(orderExcuteVo.getBizOrderlineNo());
        noticeLine.setOriginBizNo(orderExcuteVo.getBizOrderNo());
        noticeLine.setItemCode(orderExcuteVo.getItemCode());
        noticeLine.setNoticeNo(this.getNoticeNo());
        noticeLine.setQuantity(orderExcuteVo.getQuantity());
        noticeLine.setSort(orderExcuteVo.getSort());
        noticeLine.setLotNo(orderExcuteVo.getLotNo());
        noticeLine.setSubLotIndex(orderExcuteVo.getSubLotIndex());
        return noticeLine;
	}

	@Override
	public List<? extends NoticeLine> getNoticeLines() {
		return scrapOutNoticeLines;
	}
}
